import { _decorator, Component, Node } from 'cc';
import { tgxCharacterMovement, tgxThirdPersonCameraCtrl } from '../../core_tgx/tgx';
const { ccclass, property } = _decorator;

@ccclass('GomokuViewPlayer')
export class GomokuViewPlayer extends Component {
    @property(tgxCharacterMovement)
    movement: tgxCharacterMovement;

    @property(tgxThirdPersonCameraCtrl)
    cameraCtrl: tgxThirdPersonCameraCtrl;

    private _originVelocity: number = 0;
    private _originLen: number = 0;
    start() {
        this._originVelocity = this.movement.velocity;
        this._originLen = this.cameraCtrl.len;
    }

    update(deltaTime: number) {
        this.movement.velocity = this.cameraCtrl.len / this._originLen * this._originVelocity;
    }
}


